
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_EBAS_BOGPAKKE_BOG_EBAS_BOGPAKKE]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[EBAS_BOGPAKKE_BOG] DROP CONSTRAINT FK_EBAS_BOGPAKKE_BOG_EBAS_BOGPAKKE
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[FK_EBAS_FAG_EBAS_BOGPAKKE]') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE [dbo].[EBAS_FAG] DROP CONSTRAINT FK_EBAS_FAG_EBAS_BOGPAKKE
GO

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[EBAS_BOGPAKKE]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[EBAS_BOGPAKKE]
GO

CREATE TABLE [dbo].[EBAS_BOGPAKKE] (
	[GUID] [uniqueidentifier] ROWGUIDCOL NOT NULL ,
	[NR] [varchar] (50) COLLATE Danish_Norwegian_CI_AS NOT NULL ,
	[NAVN] [varchar] (255) COLLATE Danish_Norwegian_CI_AS NOT NULL 
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[EBAS_BOGPAKKE] WITH NOCHECK ADD 
	CONSTRAINT [PK_EBAS_BOGPAKKE] PRIMARY KEY  CLUSTERED 
	(
		[GUID]
	)  ON [PRIMARY] 
GO

CREATE  UNIQUE  INDEX [IDX_EBAS_BOGPAKKE_NR] ON [dbo].[EBAS_BOGPAKKE]([NR]) ON [PRIMARY]
GO

INSERT INTO EBAS_BOGPAKKE (GUID, NR, NAVN) VALUES (NEWID(), '4.03', 'Bogpakke 1')
INSERT INTO EBAS_BOGPAKKE (GUID, NR, NAVN) VALUES (NEWID(), '2.01', 'Bogpakke 2')
GO